<template>
  <div>
    <div>
      <el-collapse v-model="activeNames" @change="handleChange" class="coll_a" >
        <el-collapse-item title="重开审核" name="1" v-loading="loading" element-loading-text="Loading">
          <el-form ref="form" :model="formInline">
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item label="大病赔案号">
                  <el-input v-model="formInline.caseNo" placeholder="" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="重开赔案员工">
                  <el-input v-model="formInline.handlerName" placeholder="" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="重开赔案日期">
                  <el-input v-model="formInline.createTime" placeholder="" disabled></el-input>
                </el-form-item>
              </el-col>

            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item label="结案日期">
                  <el-input v-model="formInline.endCaseDate" placeholder="" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="重开赔案原因" prop="reopenReason" :required="true">
                  <el-select placeholder="请选择" v-model="formInline.reopenReason" disabled>
                    <el-option
                      v-for="item in OpenReason"
                      :key="item.codeCode"
                      :label="item.codeCName"
                      :value="item.codeCode">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>

            </el-row>
            <el-row type="flex">
              <el-col :span="24" style="margin-top: 20px;">
                <el-form-item label="重开原因说明" prop="reopenDescribe">
                  <el-input :rows="3" show-word-limit v-model="formInline.reopenDescribe" type="textarea"
                            disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <div class="container" style="width: 100%;margin-top: 60px;">
            <template>
              <el-tabs style="width: 100%;">
                <el-card class="box-card">
                  <div>
                    审核意见：
                    <template>
                      <el-radio v-model="auditOpinion" label="03">同意</el-radio>
                      <el-radio v-model="auditOpinion" label="04">退回</el-radio>
                    </template>
                    <br>
                    <br>
                    <div>
                      <el-input placeholder="" v-model="remark" style="width: 83%">
                        <template slot="prepend">重开备注</template>
                      </el-input>
                    </div>
                    <br>
                    <div>
                      <el-input placeholder="" v-model="evaluate" style="width: 83%">
                        <template slot="prepend">重开评语</template>
                      </el-input>
                    </div>
                  </div>
                </el-card>
              </el-tabs>
            </template>
          </div>
        </el-collapse-item>
      </el-collapse>
    </div>
    <div>
      <template>
        <div slot="footer" style="text-align: center;height: 60px;line-height: 30px" class="dialog-footer">
          <el-button type="primary" size="medium" @click="abandonTisk">放弃任务</el-button>
          <el-button :disabled="buttonShow" type="primary" @click="save()">提 交</el-button>
          <el-button type="primary" @click="fanhui()">返 回</el-button>
        </div>
      </template>
    </div>
    <el-dialog
      :visible.sync="Successdialog"
      :show-close="false"
      :close-on-click-modal="true"
      :close-on-press-escape="false"
      width="20%"
      center>
      <div style="margin-top: -35px;">
        <div>| 重开审核提交</div>
        <hr style="width: 80%;margin-left: 1px">
      </div>
      <div v-if="this.item1===0" style="text-align: center;margin-top: 20px">
        <img src="../../assets/images/pass.png" width="60">
        <div style="margin-top: 10px">{{this.message}}</div>
        <!--        <div style="margin-top: 10px">大病赔案号：{{formInline.caseNo}}</div>-->
      </div>
      <div v-if="this.item1===1" style="text-align: center;margin-top: 20px">
        <img src="../../assets/images/notPass.png" width="60">
        <div style="margin-top: 10px">提交失败</div>
        <!--        <div style="margin-top: 10px">大病赔案号：{{formInline.caseNo}}</div>-->
      </div>
      <div style="margin-top: 15px;text-align: center"><span style="font-size: x-large">{{time}}</span>秒后跳转到上一个页面</div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="researchCheckSearch" type="text" :disabled="isDisabled">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import * as api from '@/api/baseDate'

  export default {
    name: 'researchTask',
    inject: ['reload'],
    data() {
      return {
        loading: false,
        buttonShow: false,
        auditOpinion: '',
        remark: '',
        evaluate: '',
        Successdialog: false,
        query: {
          address: '',
          name: '',
          pageIndex: 1,
          pageSize: 10
        },
        dialogFormVisible: false,
        activeNames: ['1', '2'],
        //控制显示隐藏
        isBase: false,
        isSurvey: false,
        shenheyijian: "1",
        activeName: 'first',
        multipleSelection: [],
        delList: [],
        editVisible: false,
        pageTotal: 0,
        list: {},
        OpenReason: [
          {
            codeCode: '01',
            codeCName: '案后费用',
          },
          {
            codeCode: '02',
            codeCName: '法院判决',
          },
          {
            codeCode: '03',
            codeCName: '理算错误',
          }, {
            codeCode: '04',
            codeCName: '重新索赔',
          }, {
            codeCode: '05',
            codeCName: '赔款摊回',
          },
        ],
        idx: -1,
        id: -1,
        formInline: {},
        researchHistory: [
          {
            taskno: "20210721001",
            handlerOrg: "江苏省徐州",
            handler: "李刚",
            submitTime: '2021-01-01',
            surveyPass: '调查中',
            surveyResult: '通过无误',
            surveyVerdict: '可以提交审核'
          }
        ],
        message: '',
        time: 0,
        item: 0,
        item1: 0,
      };
    },
    created() {
      this.formInline = JSON.parse(this.$route.query.caseReopenAuditDemo)
      //按钮置灰
      if (this.formInline.taskState == "03") {
        this.buttonShow = true;
      }
    },
    methods: {
       //放弃任务
     abandonTisk(){
       debugger
        this.$confirm('确认放弃？')
          .then(_ => {
            api.taskCheck({
            "processId":this.$route.params.processId,
            "handleComrCode":Cookies.get("makeCom"),
            "handleComrName":Cookies.get("cMakeCom"),
            "handlerCode":Cookies.get("userCode"),
            "handlerName":Cookies.get("userName"),
            "reqFlag": "close"
          }).then(res => {
            if(res.data.resultCode=="0000"){
              this.closePageTo(this.$store,this.$route,this.$router,'caseReopenAudit');
            }else{
              this.$alert(res.data.resultMsg,'提示', {
                  confirmButtonText: '确定'
                });
            }
          })
        })
          .catch(_ => { });
      },
      saveframeCheck(){
        debugger
        var flag=true;
        if(this.auditOpinion==undefined
        ||this.auditOpinion==null
        ||this.auditOpinion==""){
          this.$alert("请选择审核意见后提交！",'提示', {
              confirmButtonText: '确定'
            });
            flag=false;
            return flag;
        }
        if(this.remark==undefined
        ||this.remark==null
        ||this.remark==""){
          this.$alert("请填写重开备注！",'提示', {
              confirmButtonText: '确定'
            });
            flag=false;
            return flag;
        }
        return flag;
      },
      save() {
        var flag=this.saveframeCheck();
        if(flag==true){
          this.loading = true;
          this.formInline.auditOpinion = this.auditOpinion,
            this.formInline.remark = this.remark,
            this.formInline.evaluate = this.evaluate,
            api.getAuditRecase(this.formInline).then(res => {
              this.loading = true;
              this.message = res.data.resultMsg;
              this.Successdialog = true
              // 把time改为5
              this.time = 5;
              // 设定一个定时器，每一秒调用一次coundDown方法，time-1
              setInterval(this.countDown, 1000);
            }).catch((function () {
                this.loading = true;
                /*let THIS = this;*/
                this.item1 = 1,
                  this.Successdialog = true
                // 把time改为5
                this.time = 5;
                // 设定一个定时器，每一秒调用一次coundDown方法，time-1
                setInterval(this.countDown, 1000);
              }),
            )
          this.loading = true;
      }
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
        this.reload();
      },
      fanhui() {
        this.$router.go(-1)
      },
      isBaseInfo() {
        this.isBase = !this.isBase;
      },
      surveyHistory() {
        this.isSurvey = !this.isSurvey;
      },
      // 分页导航
      handlePageChange(val) {
        this.$set(this.query, 'pageIndex', val);
        this.getData();
      },
      onSubmit() {
        console.log('submit!');
      },
      researchCheckSearch() {
        // this.Successdialog=false
        //this.$router.push({name:'caseReopenAudit'});
        this.closePageTo(this.$store, this.$route, this.$router, 'caseReopenAudit');
        self.close();
      },
//   封装一个方法
      countDown() {
        let THIS = this;
        THIS.time--;
      },
    },
    watch: {
      //   监听time的值
      time: function (newVal) {
        if (newVal === 0) {
          //this.$router.push({name:'caseReopenAudit'});
          this.closePageTo(this.$store, this.$route, this.$router, 'caseReopenAudit');
          self.close();
          // this.Successdialog=false
        }
      },
    },
  };
</script>

<style lang="scss" scoped>

</style>
